<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.sms.project.*, com.sms.user.*"%>
<%@ page import="net.sf.json.*"%>

<%--
	project/teacher/add-project.jsp
 --%>
<%
	//清除内存
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>

<%
	request.setCharacterEncoding("utf-8");
	String userno = session.getAttribute("userno").toString();
%>

<body>
	<div id="homework">
		
		<form id="add-homework" method="post" action="Dealaddhomework"
		target="addworkiframe"	enctype="multipart/form-data" ">
			<input type="hidden" name="fromID" value="<%=userno%>" />
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td><label for="name">*作业名称：</label>
					</td>
					<td style="text-align:left;"><input name="title" id="title"
						style="min-width:200px;" />
					</td>
				</tr>			
				<tr>
					<td><label for="deadline" style="min-width:200px;">**提交作业时间：</label>
					</td>
					<td style="text-align:left;"><input name="endtime"
						id="endtime" class="easyui-datebox" />
					</td>				
				</tr>
				
				<!--返回json数据-->
				<tr>
					<td><label for="member">*作业接收者：</label>
					</td>
					<td style="text-align:left;"><input name="member" id="member"
						style="min-width:200px;" />
					</td>
				</tr>
				<!--返回json数据-->
				<tr class="addfiles">
					<td><label for="file">添加附件：</label>
					</td>
					<td style="text-align:left;"><input type="file" name="load"
						id="file" style="min-width:200px;" />
					</td>
				</tr>
				<tr>
					<td><label for="desc">*作业内容：</label>
					</td>
					<td><textarea name="content" id="content"
							style="width:200px; height:120px; overflow:scroll;"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit"
						id="submit" value="提交" style="margin-top:10px;" />
					</td>
				</tr>
			</table>
		</form>
		<iframe name="addworkiframe" style="display:none;">
		</iframe>
	</div>
	<script type="text/javascript">		
	$(document).ready(function(){
	$("#member").combobox({
			multiple : true,
			url : 'GetStudentServlet',/*返回json数据格式的链接*/
			valueField : 'sno',
			textField : 'sname',
			editable : false,
			required : true,
			missingMessage : "此项为必填项"
		});
				

		$('#endtime').datebox(
				{
					okText : '确定',
					editable : false,
					required : true,
					missingMessage : "此项为必填项",
					formatter : function(date) {
						return date.getFullYear() + '-' + (date.getMonth() + 1)
								+ '-' + date.getDate();

					}
				});
		$('#title,#content').validatebox({
			required : true,
			missingMessage : "此项为必填项"
		});
		$("#submit").click(function(){
		
			var title = $("#title").val();
			var endtime = $('#endtime').datebox('getValue');
			var desc = $('#content').val();
			var member = $("#member").combobox('getValue');
			if (title&&endtime&&content&&member) {
				return true;
			} else {
				alert('请补充完整信息');
				return false;
			
		}
		
		});
			});
		
		function callback(msg)   
		{   
   		 	
		 	if(msg=='ok'){                              
		 		alert('添加成功');
		 	$('#dd').dialog('close');
		 		var tab = $(".easyui-tabs").tabs('getSelected');
			 $(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'homework_manage/teacher/homework_manage.jsp',
									 }
									});  /*更新面板*/
		 		
		 	}
		 	else{
			 	alert('添加不成功!');
		 	}
		 }
		
	
	</script>
</body>

